<template>
	<view class="content">
		<view style="height:400rpx;width:100%">
			<mpvue-echarts class="ec-canvas" @onInit="lineInit" canvasId="line" ref="lineChart" />
		</view>
	</view>
</template>

<script>
	import * as echarts from '@/components/echarts/echarts.simple.min.js';
	import mpvueEcharts from '@/components/mpvue-echarts/src/echarts.vue';
	let lineOption = {
		animation: true,
		color: ['#02ad81', '#bbe2e8', '#6cacde'],
		grid: {
			top: 15, //距离顶部15px
			bottom: '15%', //距离底部15%
			left: '15%',
			right: "4%"
		},
		calculable: false,
		xAxis: [{
			type: 'category',
			data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月']
		}],
		yAxis: {
			type: 'value',
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		series: [{
			type: 'bar',
			data: [120, 200, 150, 80, 70, 110, 130],
			itemStyle: {
				normal: {
					label: {
						show: true, //开启显示		
						position: 'top', //在上方显示		
						textStyle: { //数值样式			
							color: 'black',
							fontSize: 11
						}
					}
				}
			},
		}]
	};
	export default {
		data() {
			return {
				// echarts: echarts,
			}
		},
		onLoad() {

		},
		components: {
			mpvueEcharts
		},
		methods: {
			lineInit(e) {
				let {
					width,
					height
				} = e;
				let canvas = this.$refs.lineChart.canvas;
				echarts.setCanvasCreator(() => canvas);
				let lineChart = echarts.init(canvas, null, {
					width: width,
					height: height
				});
				canvas.setChart(lineChart);
				lineChart.setOption(lineOption);
				this.$refs.lineChart.setChart(lineChart);
			}
		},
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
